﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;

namespace SFast
{
    public static class LogHelper
    {
        public static MyLog InfoLogger
        {
            get
            {
                String loggerName = "InfoLogger";
                MyLog ml = NLite.Threading.Local.Get(loggerName) as MyLog;
                if (ml == null)
                {
                    NLite.Threading.Local.Set(loggerName, new MyLog(LogConfig.GetLogger(loggerName)));
                }
                return NLite.Threading.Local.Get(loggerName) as MyLog;
            }
        }
    }
    

    //
    //封装一下，如果需要统一修改日志格式或对日志进行统一监控时，可以改此代码。
    public class MyLog
    {
        private ILog log{get;set;}
        public MyLog(ILog l)
        {
            log = l;
        }

        #region debug
        public void Debug(object message)
        {
            log.Debug(message);
        }
        public void DebugFormat(String format, params object[] args)
        {
            log.DebugFormat(format, args);
        }
        #endregion

        #region info
        public void Info(object message)
        {
            log.Info(message);
        }
        public void InfoFormat(String format, params object[] args)
        {
            log.InfoFormat(format,args);
        }
        #endregion

        #region error
        public void Error(object message)
        {
            log.Error(message);
        }
        public void Error(object message,Exception exception)
        {
            log.Error(message, exception);
        }
        public void ErrorFormat(String format, params object[] args)
        {
            log.ErrorFormat(format, args);
        }
        #endregion
    }
    
}
